package com.zzstm.commonUtils;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class Base64EnCodeAndDecode {
    public static String encode(String str){
        Base64.Encoder encoder = Base64.getEncoder();
        byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
        String encodeString = encoder.encodeToString(bytes);
        return encodeString;
    }

    public static String decode(String str){
        Base64.Decoder decoder = Base64.getDecoder();
        byte[] bytes = decoder.decode(str);
        String decodeStr = new String(bytes,StandardCharsets.UTF_8);
        return decodeStr;
    }
}
